package com.itheima.registry;

import com.itheima.pojo.URL;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 薛虎
 * @date 2021/1/21 16:31
 */
public class NativeRegistry {

    /**
     * 注册中心 map
     */
    private static Map<String, Map<URL, Class>> registCenter = new HashMap<>();


    /**
     * 注册服务
     */
    public static void regist(String interfaceName, URL url, Class impClass) {

        Map<URL, Class> urlClassHashMap = new HashMap<>();
        urlClassHashMap.put(url, impClass);
        registCenter.put(interfaceName, urlClassHashMap);

    }

    /**
     * 获取服务信息
     */
    public static Class get(URL url, String interfaceName) {
        Map<URL, Class> urlClassMap = registCenter.get(interfaceName);
        Class aClass = urlClassMap.get(url);
        return aClass;
    }


}
